var sw = document.querySelector('.swiper-wrapper')
var lunbo = [
    'image/anli-1.png',
  'image/anli-2.png',
  'image/anli-3.png'
]

for(let i = 0; i < lunbo.length; i++){
  var div = document.createElement('div')
  div.className = 'swiper-slide'
  var img = document.createElement('img')
  img.src = lunbo[i]
  div.appendChild(img)
  sw.appendChild(div)
}
// 初始化swiper
var swiper = new Swiper(".swiper", {
  loop: true, // 循环模式选项
  // effect:'cube',
  autoplay:true,

  pagination: {
    el: ".swiper-pagination",
  },
});
// //发送请求获取轮播图图片
// var xhr = new XMLHttpRequest()
// xhr.open('get','http://47.116.75.38:8101/front/carousel')
// xhr.send(null)
// xhr.onload = function () {
//   var res = JSON.parse(xhr.response)
//   res.data.records.forEach(function (item) {
//     var div = document.createElement('div')
//     div.className = 'swiper-slide'
//     var img = document.createElement('img')
//     img.src = item.image
//     div.appendChild(img)
//     sw.appendChild(div)
//   })
// 初始化swiper
// var swiper = new Swiper(".swiper", {
// //   loop: true, // 循环模式选项
// //   // effect:'cube',
// //   autoplay:true,
// //
// //   pagination: {
// //     el: ".swiper-pagination",
// //   },
// // });
// }

var zz = [
    '流口水',
  '不会咀嚼',
  '讲话晚',
  '胆小',
  '不会讲话'
]

var imgs = [
  'image/anli-li-1.jpg',
  'image/anli-li-2.jpg',
  'image/anli-li-3.jpg'
]



//获取案例列表
var ul = document.querySelector('.item-ul')
var xhr = new XMLHttpRequest()
xhr.open('get','http://47.116.75.38:8101/front/case?size = 10&current = 1')
xhr.send(null)
xhr.onload = function () {
  var res = JSON.parse(xhr.response)
  res.data.records.forEach(function (item) {
    var li = document.createElement('li')
    li.className = 'ul-li'

    var a = document.createElement('a')
    a.className = 'li-a'
    a.href = 'anlizi.html?id='+item.id

    var h3 = document.createElement('h3')
    h3.innerText = zz[Math.floor(Math.random()*zz.length)]
    var div = document.createElement('div')
    div.className = 'li-lr'
    var img = document.createElement('img')
    img.src = imgs[Math.floor(Math.random()*imgs.length)]

    var div1 = document.createElement('div')
    div1.className = 'lr-r'

    var p = document.createElement('p')
    p.innerText = item.patientName +' ' + item.patientSex + ' ' + item.patientAge+'岁'
    var p1 = document.createElement('p')
    p1.innerText = '已上课时|'+item.courseTime
    var p2 = document.createElement('p')
    p2.innerText = '临床诊断|'+item.clinicalDiagnosis

    var a1 = document.createElement('a')
    a1.href = 'anlizi.html?'+item.id
    a1.className = 'ydgd'
    a1.innerText = '阅读更多'

    div1.appendChild(p)
    div1.appendChild(p1)
    div1.appendChild(p2)

    div.appendChild(img)
    div.appendChild(div1)

    a.appendChild(h3)
    a.appendChild(div)

    li.appendChild(a)
    li.appendChild(a1)

    ul.appendChild(li)
  })
}


// for(let i = 0; i < lis.length; i++){
//   lis[i].onclick = function () {
//     console.log(1)
//   }
// }
